/*
 *
 * Copyright (c) 2001-2018 泛微软件.
 * 泛微协同商务系统,版权所有.
 * 
 */

package com.engine.demo.cmd;

import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.browser.util.ConditionFactory;
import com.api.browser.util.ConditionType;
import com.cloudstore.eccom.constant.WeaResultConstant;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;

import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @version 1.0
 * @author AndyZhang
 * TODO 
 */
public class DoSearchDemoCondition extends AbstractCommonCommand<Map<String,Object>> {

	private final static Log log = LogFactory.getLog(DoUpdateDemoCmd.class);
	
    public DoSearchDemoCondition(Map<String,Object> params,User user) {
        this.user = user;
        this.params = params;
    }

    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {

    	WeaResultMsg result=new WeaResultMsg(true);
        ConditionFactory conditionFactory = new ConditionFactory(user);
        List<SearchConditionGroup> addGroups = new ArrayList<SearchConditionGroup>();
        List<SearchConditionItem> addItems = new ArrayList<SearchConditionItem>();

        //移动平台名称
        SearchConditionItem searchConditionItem = conditionFactory.createCondition(ConditionType.INPUT, 388658, "em_name");
        addItems.add(searchConditionItem);

        //选择框
        List<SearchConditionOption> searchConditionOptions = new ArrayList<>();
        searchConditionOptions.add(new SearchConditionOption("all",SystemEnv.getHtmlLabelName(332,user.getLanguage()),true));
        searchConditionOptions.add(new SearchConditionOption("enabled",SystemEnv.getHtmlLabelName(18095,user.getLanguage())));
        searchConditionOptions.add(new SearchConditionOption("disabled",SystemEnv.getHtmlLabelName(18096,user.getLanguage())));
        //状态
        SearchConditionItem searchConditionItem2 = conditionFactory.createCondition(ConditionType.SELECT, 602 , "status",searchConditionOptions);
        addItems.add(searchConditionItem2);

        //Corpid
        SearchConditionItem searchConditionItem3 = conditionFactory.createCondition(ConditionType.INPUT, 388661 , "corp_id");
        addItems.add(searchConditionItem3);

        addGroups.add(new SearchConditionGroup(SystemEnv.getHtmlLabelNames("15774",user.getLanguage()),true,addItems));
        result.put(WeaResultConstant.RESULT_CONDITIONS,addGroups);
        return result.getResultMapAll();
    }

}
